home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / BSP Tree 1.2 / Sources / Graphics / include / vector_2d.h < prev    next >
Encoding:
Text File  |  1995-03-25  |  2.1 KB  |  43 lines  |  [TEXT/MMCC]

  1. //------------------------------------------------------------------------------
  2. //    File:                    vector_2d.h
  3. //    Date:                    1/21/94
  4. //    Author:                Bretton Wade
  5. //
  6. //    Description:    this file contains the class definition for a 2d vector_2d
  7. //
  8. //------------------------------------------------------------------------------
  9.  
  10. #include "tuple_2d.h"
  11.  
  12. #ifndef    VECTOR_2D
  13. #define    VECTOR_2D
  14.  
  15. //------------------------------------------------------------------------------
  16. //    classes
  17. //------------------------------------------------------------------------------
  18. #ifndef    POINT_2D
  19. class    point_2d;                                                                                                                                    //    forward declaration
  20. #endif
  21.  
  22. //------------------------------------------------------------------------------
  23. class    vector_2d : public tuple_2d                                                                                                //    2 dimensional vector_2d class
  24. {                                                                                                                                                                //    begin vector_2d class definition
  25.     protected:                                                                                                                                        //    members internal to this class hierarchy
  26.     public:                                                                                                                                                //    public interface
  27.         vector_2d (void) {}                                                                                                                    //    default constructor
  28.         vector_2d (real x, real y);                                                                                                    //    constructor from 2 values
  29.         vector_2d (const vector_2d &v);                                                                                            //    copy constructor
  30.         vector_2d (const point_2d &p);                                                                                            //    constructor from a point
  31.         vector_2d    &operator = (const vector_2d &v);                                                                    //    assignment operator
  32.         vector_2d    operator * (real s) const;                                                                                //    scalar multiplication
  33.         vector_2d    operator / (real s) const;                                                                                //    scalar division
  34.         vector_2d    operator + (const vector_2d &v) const;                                                        //    addition operator
  35.         vector_2d    operator - (const vector_2d &v) const;                                                        //    subtraction operator
  36.         real            Norm (void) const;                                                                                                //    compute the length of the vector_2d
  37.         vector_2d    &Normalize (void);                                                                                                //    reduce the vector_2d to length 1.0
  38. };                                                                                                                                                            //    end vector_2d class definition
  39.  
  40. //------------------------------------------------------------------------------
  41.  
  42. #endif    //VECTOR_2D
  43.